Embodiments of the present invention provide a method and apparatus for chaining interrupt service routines. In particular, the present invention provides a method and apparatus for chaining interrupt service routines in systems where the interrupt vector table contains interrupt service routine instructions.
An interrupt service routine (ISR) is a routine that is executed by a microprocessor when a specific interrupt occurs. For example, a timer interrupt may occur at a given interval and may cause the execution of an interrupt service routine that updates the system clock. In most computer systems, the occurrence of an interrupt causes program flow to be routed through an interrupt vector table (IVT), which is a table that determines which interrupt service routines are executed when interrupts occur. Different interrupts may cause control to be passed to different points in the interrupt vector table. The interrupt vector table in some systems contains pointers to interrupt service routines, while in other systems the interrupt vector table contains interrupt service routine instructions. In addition, the interrupt vector table in some systems is placed in a known location in physical memory, while in other systems the interrupt vector table is not at a fixed address. Further, in some systems the size of the interrupt vector table is fixed, for example at 32 kilobytes (KB).
At times, it may become necessary to combine a new interrupt service routine with an existing interrupt service routine so that the new interrupt service routine performs an operation immediately before or after the existing interrupt service routine. For example, a new device driver may be added requiring execution of a new interrupt service routine to poll a certain hardware device each time an existing interrupt service routine updates the system clock. The interrupt service routines may be combined by modifying the call to the existing interrupt service routine, so that the new interrupt service routine is called instead of the existing interrupt service routine, and by having the new interrupt service routine jump to the existing interrupt service routine upon completion. The combination of two interrupt service routines is referred to as xe2x80x9cchainingxe2x80x9d of interrupt service routines.
In systems where the interrupt vector table is at a fixed location and contains pointers to interrupt service routines, chaining a new interrupt service routine with an existing interrupt service routine involves updating the appropriate pointer in the interrupt vector table so that it points to the new interrupt service routine, and including an instruction at the end of the new interrupt service routine that causes program flow to jump to the address of the existing interrupt service routine. Replacement of pointers cannot be used in systems for which the interrupt vector table does not contain pointers, but instead contains actual code for the interrupt service routines. In such a system, it may be difficult to store the new interrupt service routine if the system has a fixed interrupt vector table size and does not have many available empty locations in the interrupt vector table. If a system also limits the distance of Instruction Pointer (IP) relative branches, it may also be difficult to store the new interrupt service routine outside the interrupt vector table.